require.config(r_config);
require(['common','mylayer','loginReg'], function (md_common,mylayer,md_loginReg){
	var user_entry={
		init:function(){
			md_loginReg.initEvent();
			$(".u_forget_password").on("click",function(){
				md_loginReg.showForget();
			});
			$("#submit_reset").on("click",function(){
				var sub_btn=$(this);
				if(sub_btn.hasClass('disabled')){
					return false;
				}
				var reset_password=$("#reset_password");
				var password=$.trim(reset_password.val());
				if(password==""){
					reset_password.next(".error_msg").html(function(){
						return $(this).attr("data-requied");
					}).show();
					return false;
				}
				sub_btn.addClass('disabled');
				var id=$("#token").val();
				$.postAjax("/userinfo/resetPwd/"+id,{'password':password},function(result){
					sub_btn.removeClass("disabled");
					if(result.code=="0x00000"){
						mylayer.showMessage("success",result.msg,function(){
							window.location.href="/user/entry";
						});
					}
					else{
						if(result.msg){
							mylayer.showMessage('error',result.msg);
						}
						else{
							mylayer.showMessage('error',$("#system_msg").attr("data-network"));
						}
					}
					
				},function(){
					mylayer.showMessage('error',$("#system_msg").attr("data-network"));
				});
			})
		}
	}
	user_entry.init();
});
